var app = getApp();
Component({
    properties: {
        list : Array,
        params : Object
    },
    data:{
        show : true,
        showindex  : 0,
    },
    options : {
        addGlobalClass : true,
    },
    methods: {
        hide(e){
            var i = e.currentTarget.dataset.i*1;
            this.setData({
                show : false,
                showindex : i + 1,
            })
            if( this.data.list[i].istaked == 1 ){
                app.com.toast(this.data.list[i].tipstr,'none');
            }
        },
        takeit(e){
            var self = this;
            var i = e.currentTarget.dataset.i*1;
            var postdata = {
                id : this.data.list[i].id,
                op : 'takenewuser',
            };
            if(this.data.list[i].istaked*1 == 1) return false;

            app.com.http('user_v1','POST',postdata,0,true,'','',function(res){
                if (!res.data.errno && res.data) {

                    app.com.toast(res.data.message,'none');
                    if(self.data.list[i].type*1 == 1){
                        self.setData({
                            ['list['+i+'].istaked'] : 1,
                        });
                    }else{
                        self.hide(e);
                    }
                }else{
                    app.com.alert(res.data.message);
                }
            });

        },
        navigateto : function( e ){
            app.com.navigateto( e );
        },
    }

})